package cn.henu.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;

import cn.henu.model.User;
import cn.henu.service.UserService;

/**
 * @RequestMapping("/userinfo")　具有层次关系，方法级的将在类一级@RequestMapping之一,
 *                              如下面示例,　访问方法级别的
 * @RequestMapping("/new"),则URL为　/userinfo/new 　
 */
@Controller
@RequestMapping("/userinfo")
public class UserInfoController {

    //默认多列排序,example:　username　desc,createTime　asc
    protected static final String DEFAULT_SORT = null;

    private final String LIST_ACTION = "redirect:/userinfo";

    @Autowired
    private UserService userService;

    /**
     * create
     * */
    @RequestMapping(value = "/new")
    public ModelAndView create(HttpServletRequest request, HttpServletResponse response, User u)
            throws Exception {
        return new ModelAndView("/userinfo/new", "userinfo", u);

    }

    /**
     * show
     */
    @RequestMapping(value = "/{id}")
    public ModelAndView show(HttpServletRequest request, HttpServletResponse response,
            @PathVariable Long id) throws Exception {
        return new ModelAndView("/userinfo/new", "userinfo", id);

    }

}
